public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
           while(!Thread.currentThread().isInterrupted()){
               System.out.println("hello t1");
               try {
                   Thread.sleep(500);
               } catch (InterruptedException e) {
                   //e.printStackTrace();
                   break;
               }
           }
        });
        t1.start();
        Thread.sleep(5000);
        t1.interrupt();
    }
}
